package com.fhz.day013jetpackall;

import androidx.lifecycle.LiveData;

import com.fhz.day013jetpackall.entity.Banner;
import com.fhz.utilsfhz.ApiResponse;

import java.util.List;

import javax.inject.Inject;

/**
 * 时间:2022/5/31
 *
 * @author msfeng
 * 简述: TODO
 */

public class BannerRepository {

   private  BannerLocalDataSource bannerLocalDataSource;
   private BannerRemoteDataSource bannerRemoteDataSource;

   @Inject
   public BannerRepository(BannerLocalDataSource bannerLocalDataSource, BannerRemoteDataSource bannerRemoteDataSource) {
        this.bannerLocalDataSource = bannerLocalDataSource;
        this.bannerRemoteDataSource = bannerRemoteDataSource;
   }

    //远程
    public LiveData<ApiResponse<List<Banner>>> getBanner(){
        return bannerRemoteDataSource.getBanner();
    }


    //本地 插入
    public void insertBanner(Banner... banners){
       bannerLocalDataSource.insertBanner(banners);
    }

    //本地查询
    public List<Banner> getBanners(){
       return bannerLocalDataSource.getBanners();
    }



}

